﻿using System.Data.Entity.ModelConfiguration;
using QDT.Core.Projects;

namespace QDT.Core.MSData.Mapping
{
    public class ProjectMapping : EntityTypeConfiguration<Project>
    {
        public ProjectMapping()
        {
            HasKey(x => x.ID);

            Property(x => x.InnerStatus).HasColumnName("Status");

            Property(x => x.TimeStamp).IsConcurrencyToken();

            HasRequired(x => x.Parent).WithMany().HasForeignKey(x => x.ParentId);

            HasMany(x => x.ExtendAttributes).WithOptional().HasForeignKey(x => x.ProjectID).WillCascadeOnDelete(true);

            ToTable(DB.TPref("project"));
        }
    }
}
